<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
 <%@ include file="/common/taglibs.jsp" %>
 <s:if test="@org.springside.modules.security.springsecurity.SpringSecurityUtils@getCurrentUserName() == 'anonymousUser'">
	<s:include value="/admin/login.jsp" />
</s:if> <s:else>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改密码</title>
<style type="text/css">
/*password*************************************/
.change_password{
  width: 889px;
  height: 342px;
  margin: 15px auto;
  margin-left: 120px\9;
  background: url(../images/body_main_phangepassword_p.png) no-repeat;
}
.change_password form{
  width: 444px;
  padding-top: 32px;
  margin: 0 auto;
  margin: 0 222px\0;
}
.change_password .change_massage{
  padding-top: 22px;
}
.change_password .change_massage .change_classify{
  position: relative;
  margin-bottom: 25px;
}
.change_password .change_massage label{
  display: inline-block;
  font-size: 14px;
  width: 100px;
  margin-right: 7px;
  text-align: right;
  color: #181d1e;
  vertical-align: top\9;
  margin-top: 4px\9;
}
.change_password .change_massage input{
  width: 331px;
  height: 29px;
  padding: 5px;border: 1px solid #ccc;
}
.change_password .change_sure a{
  float: right;
  display: inline-block;
  width: 84px;
  height: 35px;
  text-indent: -9999px;
  background: url(${ctx }/images/body_button_ascertain_p.png) no-repeat;
}
.change_password .change_sure a:hover{
  background: url(${ctx }/images/body_button_ascertain_active_p.png) no-repeat;
}

.change_password .change_massage .ct_tip{
  position: absolute;
  left:116px;
  top: 30px\9;
}
.change_password .change_massage .ct_tip div{
  padding-left: 18px;
  background: url(${ctx }/images/body_tips_false_p.png) 0 3px no-repeat;
}
</style>
<link href="${ctx }/css/public.css" rel="stylesheet" type="text/css" />
</head>

<body>
	<div class="main">
		<div class="tip">
      <span>所在位置 :</span>
      <span class="current_position">修改密码</span>   
    </div>
    <div class="change_password">
      <form action="${ctx }/admin/administrator-admin!save.action" id="form" class="clearfix">


        <!-- 提交表单               -->
        <div class="change_massage">
          <div class="change_classify">
            <label class="name" for="user">账号:</label>
            <input type="text" value="admin" disabled="disabled" id="user" />
            <div id="tip_name" class="ct_tip"></div>
          </div>
          <!-- hidden保存旧密码id -->
          <input type="hidden" id="${entity.password}" class="old_word" style="display:none;">
          <!-- 旧密码 -->
          <div class="change_classify">
            <label class="old_password" for="old_password">旧密码:</label>
            <input type="password" id="old_password" />
            <div id="tip_old_password" class="ct_tip"></div>
          </div>
          <div class="change_classify">
            <label class="password" for="password">新密码:</label>
            <input type="password" id="password" disabled="disabled" name="password" />
            <div id="tip_password" class="ct_tip"></div>
          </div>
          <div class="change_classify">
            <label class="password_again" for="password_again">确定新密码:</label>
            <input type="password" id="password_again" disabled="disabled"  />
            <div id="tip_password_again" class="ct_tip"></div>
          </div>
        </div>
        <div class="change_sure clearfix"><a class="ac_account">登录</a></div>
      </form>
    </div>
	</div>
  <script type="text/javascript" src="${ctx }/js/public.js"></script>
  <script type="text/javascript">
        
    
  
  
    //input jugde
    var user = document.getElementById("user"),
        old_password = newdom.$("old_password"),
        password = newdom.$("password"),
        password_again = newdom.$("password_again"),
        tip_name = newdom.$("tip_name"),
        tip_password = newdom.$("tip_password"),
        tip_password_again = newdom.$("tip_password_again"),
        form = newdom.$("form"),
        ac_account = newdom.getElementsByClass("ac_account")[0],
        old_word = newdom.getElementsByClass("old_word")[0];

    //temp for account button
    var temp_3 = 3,
        temp_4 = 4;


    //function add content to obj 
    var add_content = function(obj,text){
        obj.innerHTML = text;
    }

    //旧密码判别
    var fn_blur_o = function(){
      if(old_password.value != old_word.id){
        add_content(tip_old_password,"<div>旧密码错误</div>");
        password.disabled = "disabled";
        password_again.disabled = "disabled"
      }
      else{
        add_content(tip_old_password,"");
        password.disabled = "";
        password_again.disabled = "";
      }
    }
    judge({
      kind : "password",//必传
      kind_id : "old_password",//必传
      kind_back_blur : fn_blur_o
    })

    //密码判断
    var fn_focus_p = function(){
      add_content(tip_password,"<div>请输入密码,密码长度不小于四位</div>");
    }
    var fn_blur_p = function(){
      if(password.value.length < 4){
           add_content(tip_password,'<div style="color:#C00000;">密码长度必须大于4位</div>')    
           temp_3 = 3;  
      }
      else{
           add_content(tip_password,'<div class="yes_picture"></div>') 
           temp_3 = 33;    
      }
    }
    judge({
      kind : "password",//必传
      kind_id : "password",//必传
      kind_back_focus : fn_focus_p,
      kind_back_blur : fn_blur_p
    })

    //再次输入密码
    var fn_focus_a = function(){
      if(password.value == "" || password.value.length < 4){
          add_content(tip_password_again, '<div style="color:#C00000;">请输入正确的密码</div>') 
        }
        else{
          add_content(tip_password_again,
                  "<div>请再次输入密码</div>"
          )
        }        
    }
    var fn_blur_a = function(){
      if(password.value == "" || password.value.length < 4){
         add_content(tip_password_again, '<div style="color:#C00000;">请输入正确的密码</div>') 
         temp_4 = 4;
         if(password_again.value == ""){
              temp_4 = 4;
          }
        }
        else{
          if(password_again.value == ""){
            temp_4 = 4;
          }
          else{
            if(password_again.value != password.value){
              add_content(tip_password_again,'<div style="color:#C00000;">两次输入的密码不一致</div>')
              temp_4 = 4;        
            }
            else{
              add_content(tip_password_again,'<div class="yes_picture"></div>') 
              temp_4 = 44; 
            }
          }
        }           
    }
    judge({
      kind : "password",//必传
      kind_id : "password_again",//必传
      kind_back_focus : fn_focus_a,
      kind_back_blur : fn_blur_a
    })


    ac_account.onclick = function(){
        if(old_password.value == old_word.id){
          old_password.blur();
          password.blur();
          password_again.blur();
          if(temp_3 == 33 &&temp_4 == 44){
                  form.submit();
          }
          else{
              if(temp_3 == 3 && temp_4 !=4){
                      add_content(tip_password,'<div>密码长度必须大于6位</div>')
              }
              if(temp_3 != 3 && temp_4 == 4){
                      add_content(tip_password_again,'<div>两次输入的密码不一致</div>')
              }
              if(temp_3 == 3 && temp_4 == 4){
                  add_content(tip_password,'<div>请输入正确密码</div>')
                  add_content(tip_password_again,'<div>请再次输入密码</div>')
              }
          }
        }
    }  
     
  onload =  function response(e){
    var e= '${e}';
    if(e==1){
    
    alert("密码修改成功")
    
    }
    
    }
  
  </script>
</body>
</html>
</s:else>